﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;

namespace Foundation {
    /// <summary>
    /// Stellt ein Element dar, um Tracks zu kategorisieren.
    /// </summary>
    [DataContract]
    public class Category {
        private List<Track> trackList; 
        private string name; 
        
        /// <summary>
        /// Der Name der Kategorie
        /// </summary>
        [DataMember]
        public string Name {
            get {
                return name == null ? string.Empty : this.name;
            }
            set { this.name = value; }
        }
        
        /// <summary>
        /// Die eindeutige ID der Kategorie
        /// </summary>
        [DataMember]
        public Guid ID { get; set; }

        /// <summary>
        /// Eine Liste, welche die Tracks beinhaltet, welche zur Kategorie gehören.
        /// </summary>
        [DataMember]
        public List<Track> Tracks {
            get { return trackList; }
        }

        /// <summary>
        /// Gibt die string Repräsentation der Kategorie zurück.
        /// </summary>
        /// <returns></returns>
        public override string ToString() {
            if (name != null) {
                return name;
            }
            else {
                return base.ToString();
            }
        }

        /// <summary>
        /// Konstruktor
        /// </summary>
        /// <param name="name"></param>
        public Category(string name) {            
            this.name = name;
            this.ID = Guid.NewGuid();
            this.trackList = new List<Track>(); 
        }
    }
}
